package com.ccc.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ccc.entity.User;
import com.ccc.mapper.UserMapper;
import com.ccc.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ccc
 * @since 2021-12-26
 */
@Controller
public class UserController {
    @Autowired
    UserMapper userMapper;

    /**
     * 教师获取学生的用户名密码等登录信息
     * @return
     */
    @GetMapping("/teacher/stulist")
    @PreAuthorize("hasAuthority('teacher')")
    @ResponseBody
    public ResponseResult stuList() {
        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(User::getType, "student");
        List<User> users = userMapper.selectList(wrapper);
        return new ResponseResult(200, "success", users);
    }

}
